<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Personnes extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idpersonnes;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Nom;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Prenom;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Login;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Motpass;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Mail;



    /**
     * Dependent relation fk_role_personne_personnes1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_RolePersonne
     */
    protected $_RolePersonne;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idpersonnes'=>'Idpersonnes',
            'nom'=>'Nom',
            'prenom'=>'Prenom',
            'login'=>'Login',
            'motpass'=>'Motpass',
            'mail'=>'Mail',
        ));

        $this->setParentList(array(
        ));

        $this->setDependentList(array(
            'FkRolePersonnePersonnes1' => array(
                    'property' => 'RolePersonne',
                    'table_name' => 'RolePersonne',
                ),
        ));
    }

    /**
     * Sets column idpersonnes
     *
     * @param int $data
     * @return Application_Model_Personnes
     */
    public function setIdpersonnes($data)
    {
        $this->_Idpersonnes = $data;
        return $this;
    }

    /**
     * Gets column idpersonnes
     *
     * @return int
     */
    public function getIdpersonnes()
    {
        return $this->_Idpersonnes;
    }

    /**
     * Sets column nom
     *
     * @param string $data
     * @return Application_Model_Personnes
     */
    public function setNom($data)
    {
        $this->_Nom = $data;
        return $this;
    }

    /**
     * Gets column nom
     *
     * @return string
     */
    public function getNom()
    {
        return $this->_Nom;
    }

    /**
     * Sets column prenom
     *
     * @param string $data
     * @return Application_Model_Personnes
     */
    public function setPrenom($data)
    {
        $this->_Prenom = $data;
        return $this;
    }

    /**
     * Gets column prenom
     *
     * @return string
     */
    public function getPrenom()
    {
        return $this->_Prenom;
    }

    /**
     * Sets column login
     *
     * @param string $data
     * @return Application_Model_Personnes
     */
    public function setLogin($data)
    {
        $this->_Login = $data;
        return $this;
    }

    /**
     * Gets column login
     *
     * @return string
     */
    public function getLogin()
    {
        return $this->_Login;
    }

    /**
     * Sets column motpass
     *
     * @param string $data
     * @return Application_Model_Personnes
     */
    public function setMotpass($data)
    {
        $this->_Motpass = $data;
        return $this;
    }

    /**
     * Gets column motpass
     *
     * @return string
     */
    public function getMotpass()
    {
        return $this->_Motpass;
    }

    /**
     * Sets column mail
     *
     * @param text $data
     * @return Application_Model_Personnes
     */
    public function setMail($data)
    {
        $this->_Mail = $data;
        return $this;
    }

    /**
     * Gets column mail
     *
     * @return text
     */
    public function getMail()
    {
        return $this->_Mail;
    }

    /**
     * Sets dependent relations fk_role_personne_personnes1
     *
     * @param array $data An array of Application_Model_RolePersonne
     * @return Application_Model_Personnes
     */
    public function setRolePersonne(array $data)
    {
        $this->_RolePersonne = array();

        foreach ($data as $object) {
            $this->addRolePersonne($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_role_personne_personnes1
     *
     * @param Application_Model_RolePersonne $data
     * @return Application_Model_Personnes
     */
    public function addRolePersonne(Application_Model_RolePersonne $data)
    {
        $this->_RolePersonne[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_role_personne_personnes1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_RolePersonne
     */
    public function getRolePersonne($load = true)
    {
        if ($this->_RolePersonne === null && $load) {
            $this->getMapper()->loadRelated('FkRolePersonnePersonnes1', $this);
        }

        return $this->_RolePersonne;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Personnes
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Personnes());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Personnes::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdpersonnes() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idpersonnes = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdpersonnes()));
    }
}
